import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'sub_sdk.dart';
import 'submail_one_login_plugin_platform_interface.dart';

class MethodChannelSubmailOneLoginPlugin extends SubmailOneLoginPluginPlatform {
  @visibleForTesting
  final methodChannel = const MethodChannel('com.xdr.sub_oneLogin');

  @override
  Future<dynamic> init(
      {SubPlatformConfig? androidConfig,
      SubPlatformConfig? iosConfig,
      bool debug = false,
      int timeout = 60}) {
    return methodChannel.invokeMethod('init', {
      'androidAppId': androidConfig?.appId,
      'iosAppId': iosConfig?.appId,
      'androidAppKey': androidConfig?.appKey,
      'iosAppKey': iosConfig?.appKey,
      'debug': debug,
      'timeout': timeout,
    });
  }

  @override
  Future<dynamic> getLoginAccessCode() {
    return methodChannel.invokeMethod('getLoginAccessCode');
  }

  @override
  Future<dynamic> getLoginToken() {
    return methodChannel.invokeMethod('getLoginToken');
  }

  @override
  Future<int?> getNetworkType() {
    return methodChannel.invokeMethod<int>("getNetworkType");
  }

  @override
  Future<int?> getOperatorType() {
    return methodChannel.invokeMethod<int>("getOperatorType");
  }

  @override
  Future<dynamic> getPhoneNumber() {
    return methodChannel.invokeMethod("getPhoneNumber");
  }

  @override
  Future<void> delScrip() {
    return methodChannel.invokeMethod("delScrip");
  }

  @override
  Future<void> close() {
    return methodChannel.invokeMethod("close");
  }
}
